<?php
/**
 * Nordic Repository
 * 
 * LICENSE
 * 
 * The new BSD license is applied on this source-file. For further
 * information please visit http://license.nordic-dev.de/newbsd.txt
 * or send an email to andre.moelle@gmail.com.
 */

/**
 * Necessary includes.
 */
Zend_Loader::loadClass('Zend_Auth');
Zend_Loader::loadClass('Nordic_Security_Protector_Abstract');

/**
 * Blacklist-implementation. Checks only if the user is logged in
 * before executing a method.
 * 
 * @category   Nordic
 * @package    Nordic_Security
 * @copyright  2007 Nordic Development
 * @license    http://license.nordic-dev.de/newbsd.txt (New-BSD license)
 * @author     Andre Moelle <andre.moelle@gmail.com>
 * @version    $Id: Blacklist.php 3 2007-07-08 09:21:42Z andre.moelle $
 */
class Nordic_Security_Protector_Blacklist extends Nordic_Security_Protector_Abstract
{
	/**
	 * The blacklist-implementation.
	 * 
	 * If the options does not contain the requested action, the user
	 * is always allowed to access it. Otherwise the user has to be
	 * logged in.
	 * 
	 * @see Nordic_Security_Plugin_Abstract::protect()
	 */
	public function protect ()
	{
		if(!in_array($this->getRequest()->getActionName(), $this->getOptions()))
		{
			return true;
		}
		
		return Zend_Auth::getInstance()->hasIdentity();
	}
}
?>